<?php
if (!defined ('TYPO3_MODE')) 	die ('Access denied.');
$tempColumns = Array (
	"user_farm_commerce_сcode" => Array (		
		"exclude" => 0,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_categories.user_farmcommerce_code",		
		"config" => Array (
			"type" => "input",	
			"size" => "15",	
			"max" => "255",	
			"eval" => "required,trim",
		)
	),
);


t3lib_div::loadTCA("tx_commerce_categories");
t3lib_extMgm::addTCAcolumns("tx_commerce_categories",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes("tx_commerce_categories","user_farm_commerce_сcode;;;;1-1-1");

$tempColumns = Array (
	"user_farm_commerce_pcode" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farmcommerce_code",		
		"config" => Array (
			"type" => "input",	
			"size" => "15",	
			"max" => "255",	
			"eval" => "required,trim",
		)
	),
	"user_farm_commerce_country_id" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farmcommerce_country_id",		
		"config" => Array (
			"type" => "select",	
			"foreign_table" => "static_countries",	
			"foreign_table_where" => "ORDER BY static_countries.uid",	
			"size" => 1,	
			"minitems" => 0,
			"maxitems" => 1,
		)
	),
	"user_farm_commerce_moscow_price" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farmcommerce_moscow_price",		
		"config" => Array (
			"type" => "input",	
			"size" => "15",	
			"max" => "255",	
			"eval" => "trim",
		)
	),
	"user_farm_commerce_by_request" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farmcommerce_by_request",		
		"config" => Array (
			"type" => "check",
		)
	),
	"user_farm_commerce_price_and_rest" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farmcommerce_price_and_rest",		
		"config" => Array (
			"type" => "inline",	
			"foreign_table" => "user_farm_commerce_product_branch_mm",
			"foreign_field" => "product_id",
			// "foreign_table_field" => "product_id",
			//"foreign_selector" => "branch_id",
			"foreign_unique" => "branch_id",
			"appearance" => array(
				"collapseAll" => true,
				"expandSingle" => true,
				"newRecordLinkAddTitle" => false,
				"newRecordLinkPosition" => "both",
			)
		)
	),
	"user_farm_commerce_article" => array(
		"exclude" => 1,
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farm_commerce_article",
		"config" => array(
			"type" => "input",	
			"size" => "20",	
			"max" => "150",	
			"eval" => "required,trim",
		)
	),
	"user_farm_commerce_wrapper" => array(
		"exclude" => 1,
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farm_commerce_wrapper",
		"config" => array(
			"type" => "input",	
			"size" => "20",	
			"max" => "150",	
			"eval" => "required,trim",
		)
	),
	"user_farm_commerce_dimension" => array(
		"exclude" => 1,
		"label" => "LLL:EXT:user_farm_commerce/locallang_db.xml:tx_commerce_products.user_farm_commerce_dimension",
		"config" => array(
			"type" => "input",	
			"size" => "15",	
			"max" => "50",	
			"eval" => "trim",
		)
	)
);


t3lib_div::loadTCA("tx_commerce_products");
t3lib_extMgm::addTCAcolumns("tx_commerce_products",$tempColumns,1);
//t3lib_extMgm::addToAllTCAtypes("tx_commerce_products","user_farm_commerce_pcode;;;;1-1-1, user_farm_commerce_country_id, user_farm_commerce_moscow_price, user_farm_commerce_by_request");
//$TCA['tx_commerce_products']['types']['0']['showitem'] = 'sys_language_uid;;;;1-1-1, l18n_parent, l18n_diffsource, hidden;;1, title;;;;1-1-1, user_farm_commerce_pcode, subtitle;;;;3-3-3,navtitle, description;;;richtext[cut|copy|paste|formatblock|textcolor|bold|italic|underline|left|center|right|orderedlist|unorderedlist|outdent|indent|link|table|image|line|chMode]:rte_transform[mode=ts_css|imgpath=uploads/tx_commerce/rte/], images, teaser;;;;3-3-3, teaserimages, categories;;;;4-4-4, manufacturer_uid;;;;2-2-2, relatedpage;;;;1-1-1, user_farm_commerce_country_id, user_farm_commerce_moscow_price, user_farm_commerce_by_request, user_farm_commerce_price_and_rest';
//$TCA["tx_commerce_products"][""]


$TCA["user_farm_commerce_product_branch_mm"] = array (
	"ctrl" => array (
		'title'     => 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farmcommerce_product_branch_mm',		
		'label'     => 'branch_id',	
		'tstamp'    => 'tstamp',
		'crdate'    => 'crdate',
		'cruser_id' => 'cruser_id',
		'default_sortby' => "ORDER BY crdate",	
		'delete' => 'deleted',	
		'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
		'iconfile'          => t3lib_extMgm::extRelPath($_EXTKEY).'icon_user_farmcommerce_product_branch_mm.gif',
	),
	"feInterface" => array (
		"fe_admin_fieldList" => "branch_id, branch_price, branch_price_opt, rest",
	)
);

$TCA["user_farm_commerce_discounts"] = array (
	"ctrl" => array (
		'title'		=> 'LLL:EXT:user_farm_commerce/locallang_db.xml:user_farm_commerce_discounts',
		'label'		=> 'uid',
		'tstamp'	=> 'tstamp',
		'crdate'	=> 'crdate',
		'cruser_id'	=> 'cruser_id',
		'default_sortby' => 'ORDER BY crdate',
		'delete' => 'deleted',
        'type' => 'discount_type',
        'requestUpdate' => 'discount_branch',
        'dividers2tabs' => 1,
		'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'TCA/userFarmCommerceDiscountsTca.php',
		'iconfile' 	=> t3lib_extMgm::extRelPath($_EXTKEY).'icon_user_farm_commerce_discounts.gif',
		'mainpalette' => '1'
	),
	"feInterface" => array(
		"fe_admin_fieldList" => 'discount_branch, discount_users, discount_type, categories, products, manufacturers, discount'
	)
);

	//Хуки
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getMainFieldsClass'][] = 'EXT:user_farm_commerce/hooks/class.user_productPriceTCEFormHook.php:&user_productPriceTCEFormHook';

$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:user_farm_commerce/hooks/class.tx_products_TCEhook.php:&tx_products_TCEhook';
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:user_farm_commerce/hooks/class.tx_discountsTCEhooks.php:&tx_discountsTCEhooks';
?>